{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "27bc84f9",
   "metadata": {},
   "source": [
    "-------------\n",
    "* 记录人：廖洪恩\n",
    "* 时间：2021年11月22日\n",
    "* 内容：字典的集合和数据结构综合实践"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b1574e34",
   "metadata": {},
   "source": [
    "# 上周回顾\n",
    "## 字典的实践课内、课外\n",
    "### "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "f074ab87",
   "metadata": {},
   "outputs": [],
   "source": [
    "广州南方学院 = {'status': '1',\n",
    " 'regeocode': {'roads': [{'id': '020F49F0050461206',\n",
    "    'location': '113.678,23.6284',\n",
    "    'direction': '北',\n",
    "    'name': '博学路',\n",
    "    'distance': '7.63232'},\n",
    "   {'id': '020F49F0050462229',\n",
    "    'location': '113.679,23.6245',\n",
    "    'direction': '北',\n",
    "    'name': '老虎形街',\n",
    "    'distance': '445.159'},\n",
    "   {'id': '020F49F0050462451',\n",
    "    'location': '113.677,23.6347',\n",
    "    'direction': '南',\n",
    "    'name': '中山路',\n",
    "    'distance': '708.299'}],\n",
    "  'roadinters': [{'second_name': '中山路',\n",
    "    'first_id': '020F49F0050461206',\n",
    "    'second_id': '020F49F0050462451',\n",
    "    'location': '113.676794,23.634661',\n",
    "    'distance': '708.299',\n",
    "    'first_name': '博学路',\n",
    "    'direction': '南'}],\n",
    "  'formatted_address': '广东省广州市从化区温泉镇博学路',\n",
    "  'addressComponent': {'city': '广州市',\n",
    "   'province': '广东省',\n",
    "   'adcode': '440117',\n",
    "   'district': '从化区',\n",
    "   'towncode': '440117100000',\n",
    "   'streetNumber': {'number': '24号',\n",
    "    'location': '113.677267,23.629149',\n",
    "    'direction': '西北',\n",
    "    'distance': '129.943',\n",
    "    'street': '博学路'},\n",
    "   'country': '中国',\n",
    "   'township': '温泉镇',\n",
    "   'businessAreas': [[]],\n",
    "   'building': {'name': [], 'type': []},\n",
    "   'neighborhood': {'name': [], 'type': []},\n",
    "   'citycode': '020'},\n",
    "  'aois': [],\n",
    "  'pois': [{'id': 'B0FFG4TAF2',\n",
    "    'direction': '东南',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉镇乌土村松浪队5号(近博学路)',\n",
    "    'poiweight': '0.237309',\n",
    "    'name': '广州南方公寓',\n",
    "    'location': '113.678983,23.627778',\n",
    "    'distance': '102.617',\n",
    "    'tel': '13622768437',\n",
    "    'type': '商务住宅;住宅区;住宅小区'},\n",
    "   {'id': 'B0H6FA18J5',\n",
    "    'direction': '东南',\n",
    "    'businessarea': [],\n",
    "    'address': '从莞深高速(广州南方学院南侧)',\n",
    "    'poiweight': '0.223065',\n",
    "    'name': '保利半山花园',\n",
    "    'location': '113.679358,23.627672',\n",
    "    'distance': '139.054',\n",
    "    'tel': [],\n",
    "    'type': '商务住宅;住宅区;住宅区'},\n",
    "   {'id': 'B00140TWHT',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '笃行路2',\n",
    "    'poiweight': '0.157653',\n",
    "    'name': '教工住宅1号',\n",
    "    'location': '113.678490,23.630432',\n",
    "    'distance': '222.658',\n",
    "    'tel': [],\n",
    "    'type': '商务住宅;住宅区;住宅小区'},\n",
    "   {'id': 'B0FFHRJDM9',\n",
    "    'direction': '东南',\n",
    "    'businessarea': [],\n",
    "    'address': '中大南方学院南门1号',\n",
    "    'poiweight': '0.256152',\n",
    "    'name': '中南公寓',\n",
    "    'location': '113.680349,23.627573',\n",
    "    'distance': '231.723',\n",
    "    'tel': '13711245345',\n",
    "    'type': '商务住宅;住宅区;住宅小区'},\n",
    "   {'id': 'B0HGD588HJ',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院教学楼4号',\n",
    "    'location': '113.677460,23.630490',\n",
    "    'distance': '242.901',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0FFHZH0IK',\n",
    "    'direction': '西北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路广州南方学院综合楼内',\n",
    "    'poiweight': '0.17934',\n",
    "    'name': '地下铁',\n",
    "    'location': '113.677941,23.629029',\n",
    "    'distance': '74.1376',\n",
    "    'tel': [],\n",
    "    'type': '餐饮服务;冷饮店;冷饮店'},\n",
    "   {'id': 'B0HGDU76L2',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院2号实验楼',\n",
    "    'location': '113.678211,23.630956',\n",
    "    'distance': '280.003',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0FFKP838K',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路25',\n",
    "    'poiweight': '0.191742',\n",
    "    'name': '教学楼3号(外国语学院)',\n",
    "    'location': '113.677247,23.630947',\n",
    "    'distance': '298.093',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;高等院校'},\n",
    "   {'id': 'B0HGDU8NLD',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路附近',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院1号实验楼',\n",
    "    'location': '113.678215,23.631370',\n",
    "    'distance': '326.007',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0HGD58UTU',\n",
    "    'direction': '西北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路',\n",
    "    'poiweight': '0.191229',\n",
    "    'name': '广州南方学院2号教学楼',\n",
    "    'location': '113.677060,23.631346',\n",
    "    'distance': '346.352',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B00140MR9A',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉大道882号',\n",
    "    'poiweight': '0.450402',\n",
    "    'name': '广州南方学院',\n",
    "    'location': '113.679262,23.632583',\n",
    "    'distance': '471.564',\n",
    "    'tel': '020-87828988;020-61787331',\n",
    "    'type': '科教文化服务;学校;高等院校'},\n",
    "   {'id': 'B0HGDU92JD',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': [],\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院教学楼1号',\n",
    "    'location': '113.677077,23.631783',\n",
    "    'distance': '391.548',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0HGD592BJ',\n",
    "    'direction': '东北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉大道886号广州南方学院内',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院综合楼',\n",
    "    'location': '113.680117,23.631544',\n",
    "    'distance': '392.731',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0FFKP81F0',\n",
    "    'direction': '西北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路19号附近',\n",
    "    'poiweight': '0.191742',\n",
    "    'name': '教学楼1号(文学与传媒学院)',\n",
    "    'location': '113.676866,23.631736',\n",
    "    'distance': '393.93',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;科教文化场所;科教文化场所'},\n",
    "   {'id': 'B0FFLBEOND',\n",
    "    'direction': '东北',\n",
    "    'businessarea': [],\n",
    "    'address': '从莞深高速(广州南方学院)',\n",
    "    'poiweight': '0.190963',\n",
    "    'name': '聚贤楼10号',\n",
    "    'location': '113.681253,23.631036',\n",
    "    'distance': '418.51',\n",
    "    'tel': [],\n",
    "    'type': '商务住宅;住宅区;宿舍'},\n",
    "   {'id': 'B0FFH6K3U9',\n",
    "    'direction': '西北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉镇温泉大道882号广州南方学院H7栋1-5层',\n",
    "    'poiweight': '0.254885',\n",
    "    'name': '广州中大南方招待所',\n",
    "    'location': '113.676330,23.631332',\n",
    "    'distance': '378.102',\n",
    "    'tel': '020-61787222',\n",
    "    'type': '住宿服务;住宿服务相关;住宿服务相关'},\n",
    "   {'id': 'B0HGD58NF8',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉大道882号广州南方学院新综合楼2层',\n",
    "    'poiweight': '0.191229',\n",
    "    'name': '广州南方学院达人书院',\n",
    "    'location': '113.679041,23.632392',\n",
    "    'distance': '446.366',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;科教文化场所;科教文化场所'},\n",
    "   {'id': 'B0FFKUVYWV',\n",
    "    'direction': '东北',\n",
    "    'businessarea': [],\n",
    "    'address': '保利桃花源',\n",
    "    'poiweight': '0.273168',\n",
    "    'name': '广州和风庭阿七度假别墅',\n",
    "    'location': '113.681736,23.630569',\n",
    "    'distance': '424.35',\n",
    "    'tel': '18681565305',\n",
    "    'type': '住宿服务;住宿服务相关;住宿服务相关'},\n",
    "   {'id': 'B0HGDU99RM',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉大道882号广州南方学院内',\n",
    "    'poiweight': '0.257947',\n",
    "    'name': '广州南方学院图书馆',\n",
    "    'location': '113.679177,23.632762',\n",
    "    'distance': '489.331',\n",
    "    'tel': '020-61787368;020-61787371',\n",
    "    'type': '科教文化服务;图书馆;图书馆'},\n",
    "   {'id': 'B0HGDU92JC',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路附近',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院4号实验楼',\n",
    "    'location': '113.679963,23.632652',\n",
    "    'distance': '498.883',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0FFL7C054',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉镇博学路882号(广州南方学院商业中心1层)',\n",
    "    'poiweight': '0.317505',\n",
    "    'name': '广州U优森特酒店',\n",
    "    'location': '113.679226,23.632528',\n",
    "    'distance': '464.819',\n",
    "    'tel': '15813395296',\n",
    "    'type': '住宿服务;住宿服务相关;住宿服务相关'},\n",
    "   {'id': 'B0FFG8CSEK',\n",
    "    'direction': '东北',\n",
    "    'businessarea': [],\n",
    "    'address': '从莞深高速(广州南方学院)',\n",
    "    'poiweight': '0.185371',\n",
    "    'name': 'L5员工宿舍',\n",
    "    'location': '113.682583,23.631487',\n",
    "    'distance': '554.129',\n",
    "    'tel': [],\n",
    "    'type': '商务住宅;住宅区;宿舍'},\n",
    "   {'id': 'B0HGD58FR2',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '广州南方学院',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院教学楼9号',\n",
    "    'location': '113.679747,23.633032',\n",
    "    'distance': '532.163',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0HG5Z9JNK',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路',\n",
    "    'poiweight': '0.221553',\n",
    "    'name': '广州南方学院教学楼7号',\n",
    "    'location': '113.678600,23.633330',\n",
    "    'distance': '544.868',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0HGD599JM',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉大道882号广州南方学院',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院第11教学楼',\n",
    "    'location': '113.680037,23.633173',\n",
    "    'distance': '556.036',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0GUJYPEG2',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉大道882号广州南方学院内博学路6号之3',\n",
    "    'poiweight': '0.216026',\n",
    "    'name': '怒烤烤串(从化店)',\n",
    "    'location': '113.677160,23.632910',\n",
    "    'distance': '510.112',\n",
    "    'tel': [],\n",
    "    'type': '餐饮服务;中餐厅;特色/地方风味餐厅'},\n",
    "   {'id': 'B0HGDU6Z41',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉大道882',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院教学楼6号',\n",
    "    'location': '113.678424,23.633710',\n",
    "    'distance': '586.331',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0HGD580NZ',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路7号附近',\n",
    "    'poiweight': '0.285712',\n",
    "    'name': '广州南方学院惟贤门',\n",
    "    'location': '113.678437,23.633721',\n",
    "    'distance': '587.601',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;高等院校'},\n",
    "   {'id': 'B0HGDU7T1K',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '从莞深高速(广州南方学院)',\n",
    "    'poiweight': '0.191229',\n",
    "    'name': '广州南方学院教学楼10号',\n",
    "    'location': '113.680125,23.633492',\n",
    "    'distance': '592.504',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;科教文化场所;科教文化场所'},\n",
    "   {'id': 'B0HGDU76L1',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '中山路与博学路交叉口东南150米',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院教学楼5号',\n",
    "    'location': '113.678046,23.633982',\n",
    "    'distance': '616.848',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'}]},\n",
    " 'info': 'OK',\n",
    " 'infocode': '10000'}\n",
    "#广州南方学院"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "4a2faf2e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dict_keys(['status', 'regeocode', 'info', 'infocode'])"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#先从keys和value观察字典\n",
    "# keys有多少关键字属性  values：可以观察具体的属性内容\n",
    "广州南方学院.keys()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "4a417b2c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'1'"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "广州南方学院['status']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "dcad7e5a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'OK'"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "广州南方学院['info']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "01a0e2eb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'10000'"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "广州南方学院['infocode']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "f6d0f0a6",
   "metadata": {},
   "outputs": [],
   "source": [
    "广州南方学院_regeocode = 广州南方学院[ 'regeocode']#找到核心数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "e8366e06",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dict_keys(['roads', 'roadinters', 'formatted_address', 'addressComponent', 'aois', 'pois'])"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "广州南方学院[ 'regeocode'].keys()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "acab826c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'id': '020F49F0050461206',\n",
       "  'location': '113.678,23.6284',\n",
       "  'direction': '北',\n",
       "  'name': '博学路',\n",
       "  'distance': '7.63232'},\n",
       " {'id': '020F49F0050462229',\n",
       "  'location': '113.679,23.6245',\n",
       "  'direction': '北',\n",
       "  'name': '老虎形街',\n",
       "  'distance': '445.159'},\n",
       " {'id': '020F49F0050462451',\n",
       "  'location': '113.677,23.6347',\n",
       "  'direction': '南',\n",
       "  'name': '中山路',\n",
       "  'distance': '708.299'}]"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "广州南方学院_regeocode['roads']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "8f3d9574",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'second_name': '中山路',\n",
       "  'first_id': '020F49F0050461206',\n",
       "  'second_id': '020F49F0050462451',\n",
       "  'location': '113.676794,23.634661',\n",
       "  'distance': '708.299',\n",
       "  'first_name': '博学路',\n",
       "  'direction': '南'}]"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "广州南方学院_regeocode['roadinters']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "e0174c5e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广东省广州市从化区温泉镇博学路'"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "广州南方学院_regeocode['formatted_address']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "02b930dc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'city': '广州市',\n",
       " 'province': '广东省',\n",
       " 'adcode': '440117',\n",
       " 'district': '从化区',\n",
       " 'towncode': '440117100000',\n",
       " 'streetNumber': {'number': '24号',\n",
       "  'location': '113.677267,23.629149',\n",
       "  'direction': '西北',\n",
       "  'distance': '129.943',\n",
       "  'street': '博学路'},\n",
       " 'country': '中国',\n",
       " 'township': '温泉镇',\n",
       " 'businessAreas': [[]],\n",
       " 'building': {'name': [], 'type': []},\n",
       " 'neighborhood': {'name': [], 'type': []},\n",
       " 'citycode': '020'}"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "广州南方学院_regeocode['addressComponent']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "e9fde1c4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "广州南方学院_regeocode['aois']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "f9acccf1",
   "metadata": {},
   "outputs": [],
   "source": [
    "广州南方学院_regeocode_pois = 广州南方学院_regeocode['pois']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "ff9b1f99",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "30"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 操作列表\n",
    "# 1、查看列表的长度len()\n",
    "# 2、查看其中任意一个数据的形式和属性\n",
    "len(广州南方学院['regeocode']['pois'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "2ad29ff1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'id': 'B0FFG4TAF2',\n",
       " 'direction': '东南',\n",
       " 'businessarea': [],\n",
       " 'address': '温泉镇乌土村松浪队5号(近博学路)',\n",
       " 'poiweight': '0.237309',\n",
       " 'name': '广州南方公寓',\n",
       " 'location': '113.678983,23.627778',\n",
       " 'distance': '102.617',\n",
       " 'tel': '13622768437',\n",
       " 'type': '商务住宅;住宅区;住宅小区'}"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "广州南方学院['regeocode']['pois'][0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "253c8004",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "B0FFG4TAF2\n",
      "B0H6FA18J5\n",
      "B00140TWHT\n",
      "B0FFHRJDM9\n",
      "B0HGD588HJ\n",
      "B0FFHZH0IK\n",
      "B0HGDU76L2\n",
      "B0FFKP838K\n",
      "B0HGDU8NLD\n",
      "B0HGD58UTU\n",
      "B00140MR9A\n",
      "B0HGDU92JD\n",
      "B0HGD592BJ\n",
      "B0FFKP81F0\n",
      "B0FFLBEOND\n",
      "B0FFH6K3U9\n",
      "B0HGD58NF8\n",
      "B0FFKUVYWV\n",
      "B0HGDU99RM\n",
      "B0HGDU92JC\n",
      "B0FFL7C054\n",
      "B0FFG8CSEK\n",
      "B0HGD58FR2\n",
      "B0HG5Z9JNK\n",
      "B0HGD599JM\n",
      "B0GUJYPEG2\n",
      "B0HGDU6Z41\n",
      "B0HGD580NZ\n",
      "B0HGDU7T1K\n",
      "B0HGDU76L1\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "['B0FFG4TAF2',\n",
       " 'B0H6FA18J5',\n",
       " 'B00140TWHT',\n",
       " 'B0FFHRJDM9',\n",
       " 'B0HGD588HJ',\n",
       " 'B0FFHZH0IK',\n",
       " 'B0HGDU76L2',\n",
       " 'B0FFKP838K',\n",
       " 'B0HGDU8NLD',\n",
       " 'B0HGD58UTU',\n",
       " 'B00140MR9A',\n",
       " 'B0HGDU92JD',\n",
       " 'B0HGD592BJ',\n",
       " 'B0FFKP81F0',\n",
       " 'B0FFLBEOND',\n",
       " 'B0FFH6K3U9',\n",
       " 'B0HGD58NF8',\n",
       " 'B0FFKUVYWV',\n",
       " 'B0HGDU99RM',\n",
       " 'B0HGDU92JC',\n",
       " 'B0FFL7C054',\n",
       " 'B0FFG8CSEK',\n",
       " 'B0HGD58FR2',\n",
       " 'B0HG5Z9JNK',\n",
       " 'B0HGD599JM',\n",
       " 'B0GUJYPEG2',\n",
       " 'B0HGDU6Z41',\n",
       " 'B0HGD580NZ',\n",
       " 'B0HGDU7T1K',\n",
       " 'B0HGDU76L1']"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 2、请找出所有的 pois 中的字典元素 的 id，存到一个id列表中\n",
    "id_list = []\n",
    "for i in 广州南方学院_regeocode_pois:\n",
    "    print(i['id'])\n",
    "    id_list.append(i['id'])\n",
    "id_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "id": "0129cd18",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "广州南方公寓\n",
      "保利半山花园\n",
      "教工住宅1号\n",
      "中南公寓\n",
      "广州南方学院教学楼4号\n",
      "地下铁\n",
      "广州南方学院2号实验楼\n",
      "教学楼3号(外国语学院)\n",
      "广州南方学院1号实验楼\n",
      "广州南方学院2号教学楼\n",
      "广州南方学院\n",
      "广州南方学院教学楼1号\n",
      "广州南方学院综合楼\n",
      "教学楼1号(文学与传媒学院)\n",
      "聚贤楼10号\n",
      "广州中大南方招待所\n",
      "广州南方学院达人书院\n",
      "广州和风庭阿七度假别墅\n",
      "广州南方学院图书馆\n",
      "广州南方学院4号实验楼\n",
      "广州U优森特酒店\n",
      "L5员工宿舍\n",
      "广州南方学院教学楼9号\n",
      "广州南方学院教学楼7号\n",
      "广州南方学院第11教学楼\n",
      "怒烤烤串(从化店)\n",
      "广州南方学院教学楼6号\n",
      "广州南方学院惟贤门\n",
      "广州南方学院教学楼10号\n",
      "广州南方学院教学楼5号\n"
     ]
    }
   ],
   "source": [
    "# 3、请找出所有的 pois 中的字典元素 的 name，存到一个 id 列表中\n",
    "for i in 广州南方学院_regeocode_pois:\n",
    "    print(i['name'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "id": "d4b69f00",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "广州南方学院教学楼4号\n",
      "教学楼3号(外国语学院)\n",
      "广州南方学院2号教学楼\n",
      "广州南方学院教学楼1号\n",
      "教学楼1号(文学与传媒学院)\n",
      "广州南方学院教学楼9号\n",
      "广州南方学院教学楼7号\n",
      "广州南方学院第11教学楼\n",
      "广州南方学院教学楼6号\n",
      "广州南方学院教学楼10号\n",
      "广州南方学院教学楼5号\n"
     ]
    }
   ],
   "source": [
    "# 4、请找出所有的教学楼 在上体中多一步筛选 if和else\n",
    "for i in 广州南方学院_regeocode_pois:\n",
    "    if \"教学楼\" in i['name']:\n",
    "        print (i['name'])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "id": "6f2b5d2a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'id': 'B0HGD588HJ', 'direction': '北', 'businessarea': [], 'address': '博学路', 'poiweight': '0.221662', 'name': '广州南方学院教学楼4号', 'location': '113.677460,23.630490', 'distance': '242.901', 'tel': [], 'type': '科教文化服务;学校;学校'}\n",
      "{'id': 'B0FFKP838K', 'direction': '北', 'businessarea': [], 'address': '博学路25', 'poiweight': '0.191742', 'name': '教学楼3号(外国语学院)', 'location': '113.677247,23.630947', 'distance': '298.093', 'tel': [], 'type': '科教文化服务;学校;高等院校'}\n",
      "{'id': 'B0HGDU92JD', 'direction': '北', 'businessarea': [], 'address': [], 'poiweight': '0.221662', 'name': '广州南方学院教学楼1号', 'location': '113.677077,23.631783', 'distance': '391.548', 'tel': [], 'type': '科教文化服务;学校;学校'}\n",
      "{'id': 'B0HGD58FR2', 'direction': '北', 'businessarea': [], 'address': '广州南方学院', 'poiweight': '0.221662', 'name': '广州南方学院教学楼9号', 'location': '113.679747,23.633032', 'distance': '532.163', 'tel': [], 'type': '科教文化服务;学校;学校'}\n",
      "{'id': 'B0HG5Z9JNK', 'direction': '北', 'businessarea': [], 'address': '博学路', 'poiweight': '0.221553', 'name': '广州南方学院教学楼7号', 'location': '113.678600,23.633330', 'distance': '544.868', 'tel': [], 'type': '科教文化服务;学校;学校'}\n",
      "{'id': 'B0HGD599JM', 'direction': '北', 'businessarea': [], 'address': '温泉大道882号广州南方学院', 'poiweight': '0.221662', 'name': '广州南方学院第11教学楼', 'location': '113.680037,23.633173', 'distance': '556.036', 'tel': [], 'type': '科教文化服务;学校;学校'}\n",
      "{'id': 'B0HGDU6Z41', 'direction': '北', 'businessarea': [], 'address': '温泉大道882', 'poiweight': '0.221662', 'name': '广州南方学院教学楼6号', 'location': '113.678424,23.633710', 'distance': '586.331', 'tel': [], 'type': '科教文化服务;学校;学校'}\n",
      "{'id': 'B0HGDU7T1K', 'direction': '北', 'businessarea': [], 'address': '从莞深高速(广州南方学院)', 'poiweight': '0.191229', 'name': '广州南方学院教学楼10号', 'location': '113.680125,23.633492', 'distance': '592.504', 'tel': [], 'type': '科教文化服务;科教文化场所;科教文化场所'}\n",
      "{'id': 'B0HGDU76L1', 'direction': '北', 'businessarea': [], 'address': '中山路与博学路交叉口东南150米', 'poiweight': '0.221662', 'name': '广州南方学院教学楼5号', 'location': '113.678046,23.633982', 'distance': '616.848', 'tel': [], 'type': '科教文化服务;学校;学校'}\n"
     ]
    }
   ],
   "source": [
    "#  5、找出朝北\n",
    "for i in 广州南方学院_regeocode_pois:\n",
    "    if \"教学楼\" in i['name']:\n",
    "        if i['direction'] == '北':\n",
    "            print(i)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ab847ca1",
   "metadata": {},
   "source": [
    "# 集合\n",
    "> 1.集合的概念（）\n",
    "> 2.集合的形式{value1，value2，value3....}\n",
    "> 3.唯一性（去除重复项:一般可以查看列表成员的属性）\n",
    "> 4.可变性\n",
    "> 5.集合可以用in进行成员的查询"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "439b24b4",
   "metadata": {},
   "outputs": [],
   "source": [
    "basket = {'apple','orange','apple','pear','orange','banana'}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "a8085e7e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'set'> \n",
      " {'orange', 'pear', 'apple', 'banana'}\n"
     ]
    }
   ],
   "source": [
    "print(type(basket),'\\n',basket)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "414f7e73",
   "metadata": {},
   "source": [
    "## 集合的运算\n",
    "## 集合的一般方法\n",
    "> 1.交集运算 set1.intersection（set2）用符号set1 & set2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "0e7afb2c",
   "metadata": {},
   "outputs": [],
   "source": [
    "list_1 = [1,2,5,6,7,2,3,4,4]\n",
    "set_1 = set(list_1) # list to set "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "b075c14b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1, 2, 3, 4, 5, 6, 7}"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set_1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "2b642cb1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{0, 1, 3, 4, 7, 8, 66}"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set_2 = set([1,3,4,0,8,66,7])\n",
    "set_2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "d47ee7af",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function intersection:\n",
      "\n",
      "intersection(...) method of builtins.set instance\n",
      "    Return the intersection of two sets as a new set.\n",
      "    \n",
      "    (i.e. all elements that are in both sets.)\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(set_1.intersection)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "1c3ec65d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1, 3, 4, 7}"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_intersection = set_1.intersection(set_2)\n",
    "new_intersection"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4a81abef",
   "metadata": {},
   "source": [
    "> 2.集合的并集运算 set_1.union（set2） 用符号set1 | set2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "3eaaf3bf",
   "metadata": {},
   "outputs": [],
   "source": [
    "list_1 = [1,2,5,6,7,2,3,4,4]\n",
    "set_1 = set(list_1) # list to set "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "5ad1d171",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1, 2, 3, 4, 5, 6, 7}"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set_1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "c33e49fc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{0, 1, 3, 4, 7, 8, 66}"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set_2 = set([1,3,4,0,8,66,7])\n",
    "set_2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "a6e13241",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{0, 1, 2, 3, 4, 5, 6, 7, 8, 66}"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_union = set_1.union(set_2)\n",
    "new_union"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e9394051",
   "metadata": {},
   "source": [
    "> 3.差值的运算 set1.difference（set2）用符号set1 - set2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "f0f54dda",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1, 2, 3, 4, 5, 6, 7}"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set_1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "5a6bd239",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{0, 1, 3, 4, 7, 8, 66}"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set_2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "fea2742e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{2, 5, 6}"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set_1 - set_2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "8547f99f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{2, 5, 6}"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set_1.difference(set_2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "86b568ed",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{0, 8, 66}"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set_2.difference(set_1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "d977e0cf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{0, 2, 5, 6, 8, 66}"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set_1.symmetric_difference(set_2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "115d9ad1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{0, 2, 5, 6, 8, 66}"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set_2.symmetric_difference(set_1)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a3d9e4bf",
   "metadata": {},
   "source": [
    "## 集合的一般方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "id": "61c96c77",
   "metadata": {},
   "outputs": [],
   "source": [
    "set_3 = set([1,3,4,0,8,66,7])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "54680d24",
   "metadata": {},
   "source": [
    "> 4.增加 add（）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "41fc4624",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function add:\n",
      "\n",
      "add(...) method of builtins.set instance\n",
      "    Add an element to a set.\n",
      "    \n",
      "    This has no effect if the element is already present.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help (set_3.add)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "id": "3b4f116c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{0, 1, 66, 3, 4, 7, 8}\n"
     ]
    }
   ],
   "source": [
    "set_1.add(9)\n",
    "print(set_3)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "58e22548",
   "metadata": {},
   "source": [
    "> 5.删除pop（），remove（）,discard(member)不会报错 remove（）先查看成员in是否存在"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "id": "2d4963a1",
   "metadata": {},
   "outputs": [],
   "source": [
    "set_3 = set([1,3,4,0,8,66,7])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "id": "4aaa6ff9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function pop:\n",
      "\n",
      "pop(...) method of builtins.set instance\n",
      "    Remove and return an arbitrary set element.\n",
      "    Raises KeyError if the set is empty.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(set_3.pop)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "id": "ce1c1965",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 96,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set_3.pop()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "id": "70bd7c7f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{1, 66, 3, 4, 7, 8}\n"
     ]
    }
   ],
   "source": [
    "print(set_3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "id": "8e007613",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function remove:\n",
      "\n",
      "remove(...) method of builtins.set instance\n",
      "    Remove an element from a set; it must be a member.\n",
      "    \n",
      "    If the element is not a member, raise a KeyError.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(set_3.remove)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "id": "0d8801b3",
   "metadata": {},
   "outputs": [],
   "source": [
    "if 66 in set_3:\n",
    "    set_3.remove(66)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "id": "2588a858",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function discard:\n",
      "\n",
      "discard(...) method of builtins.set instance\n",
      "    Remove an element from a set if it is a member.\n",
      "    \n",
      "    If the element is not a member, do nothing.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(set_3.discard)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "id": "15686532",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1, 3, 4, 7, 8}"
      ]
     },
     "execution_count": 102,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set_3.discard(9)\n",
    "set_3"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9ff5a59c",
   "metadata": {},
   "source": [
    "## 集合实践（课本）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "6803a434",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Provide a word to search for vowels:hongen\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'e', 'o'}"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "vowels = set('aeiou')\n",
    "word = input(\"Provide a word to search for vowels:\")\n",
    "found = vowels.intersection(set(word))\n",
    "found"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4bd8b842",
   "metadata": {},
   "source": [
    "## 下周第四章 函数与模块（重要）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cb402abd",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
